package ru.incoremedia.gwttest.core.server.util;

import java.io.InputStream;
import java.util.Properties;

public class ResourcePropertyReader {

    private final String fullClassPath;

    /*
    * @param fullClassPath Full classpath begining from "/". F.e. "/org/blacktech/lambda/my.properties"
    */
    public ResourcePropertyReader(String fullClassPath) {
        this.fullClassPath = fullClassPath;
    }

    public String readProperty(String name) throws Exception {
        Properties settings = new Properties();
        InputStream in = getClass().getResourceAsStream(fullClassPath);

        try {
            settings.load(in);
            return settings.getProperty(name);
        }
        finally {
            in.close();
        }
    }
}
